import 'package:get/get.dart';

class CountController extends GetxController {
  var count = 0.obs;
  var isOpen = true.obs;
  Worker? isOpenWorker;
  void inc() {
    count++;
  }
  void dec(){
    count--;
  }

  void open() {
    isOpen.value  = true;
  }
  void close(){
    isOpen.value = false;
  }
  @override
  void onInit() {
    isOpenWorker = ever(isOpen, (value) {
      //每一次的修改都会调用,build不会
      print('ever: $value');
    });
    super.onInit();
  }
  @override
  void onClose() {

    isOpenWorker?.dispose();
    super.onClose();
  }
}
